home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gamers Delight 2
/
Gamers Delight 2.iso
/
Aminet
/
game
/
role
/
SRunMatGen.lha
/
MatrixGen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-26
|
15KB
|
430 lines
/*********************************/
/* MatrixGenerator für ShadowRun */
/* written by Thomas Reinhardt */
/* */
/* all rights reserved */
/* */
/* CPU - 1 */
/* SPU - 2 */
/* IOP - 3 */
/* DS - 4 */
/* SAN - 5 */
/* SN - 6 */
/*********************************/
#include <time.h>
#include <math.h>
#include <string.h>
#include <exec/interrupts.h>
#include <exec/libraries.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include <exec/nodes.h>
#include <exec/ports.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/diskfont.h>
#include <stdio.h>
#include <stdlib.h>
#include "MatrixGen.h"
#include "all.h"
LONG SaveNamePointer;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *DosBase;
struct NewScreen MyNewScreen;
struct Screen *MyScreen;
struct BitMapHeader BMHD;
struct ColorRegister Colors[16];
struct CommodoreAmiga CAMG;
LONG Len,xi,yi,b;
ULONG ChunkLen;
char *WohinDamit;
char GfxName[255];
char StatusName[255];
char StandardName[255];
char TextName[255];
char DatenFeld[255];
BOOL success,AllDone;
int i;
char inread[5];
int cBitmaps,AnzahlKnoten,AusgangsKnoten,AnzahlWichtigeDaten,Stufenwert;
int MaxSAN,AusgangsWichtigeDaten;
UBYTE xPos,yPos,MaxFarben,Language,OutputType;
struct MatrixKomponenten Matrix[12*12];
struct MatrixGenType MatrixDatas[1];
BOOL CPUInSystem=FALSE,Beenden=FALSE,RandomDSValue,CheckLevelCode;
BOOL Zufallsstufen,KeineDatenspeicher,StatusFile,PrefsFile,BlaueKnoten;
BOOL Schatten,SaveDatenfeld,InstallNoIC,AlwaysICInfo,AlwaysICDS,LoadDataField;
UBYTE AnzahlCPU,AnzahlSPU,AnzahlDS,AnzahlSAN,AnzahlSN,AnzahlIOP,AnzahlBlueNodes;
int main(int argc,char **argv){
srand((unsigned)time(NULL));
cBitmaps=4;
AnzahlKnoten=20;
MaxFarben=5;
Language=0;
OutputType=0;
Zufallsstufen=FALSE;
KeineDatenspeicher=FALSE;
AnzahlWichtigeDaten=5;
StatusFile=FALSE;
Zufallsstufen=TRUE;
Stufenwert=3;
MaxSAN=2;
RandomDSValue=FALSE;
PrefsFile=FALSE;
BlaueKnoten=FALSE;
Schatten=FALSE;
SaveDatenfeld=FALSE;
InstallNoIC=FALSE;
AlwaysICInfo=FALSE;
AlwaysICDS=FALSE;
LoadDataField=FALSE;
CheckLevelCode=FALSE;
strcpy(StandardName,"RAM:Matrix");
strcpy(StatusName,"RAM:Matrix.STAT");
strcpy(TextName,"RAM:Matrix.DOC");
strcpy(GfxName,"RAM:Matrix.IFF");
strcpy(DatenFeld,"RAM:Matrix.SRC");
if(strncmp(argv[1],"?",1)==0){
printf("USAGE\n");
printf(" MatrixGen -a <Nodes> -b -d -f -g -h -i <MaxData> -l <g> -m -n -r <Level>\n");
printf(" -s <Name> -t -u -v -x -z\n");
printf("OR\n");
printf(" MatrixGen -p OR MatrixGen -o <File>\n");
printf("\n");
printf(" -p/-P Using Prefs-File MatrixGen.pre\n");
printf("\n");
printf(" -a/-A Number Of Nodes In System (between 5 and 100)\n");
printf(" -b/-B Blue-Nodes (No IC, No Value, No Information)\n");
printf(" -c/-C Check Level and Code\n");
printf(" -d/-D save datafield of the program\n");
printf(" -f/-F Status-File-Name\n");
printf(" -g/-G German Version (purble/black nodes)\n");
printf(" -h/-H Draw Nodes With Shadow\n");
printf(" -i/-I Number Important Datas\n");
printf(" -l/-L Language [g(erman)]\n");
printf(" -m/-M Maximal Number Of SAN (1..10)\n");
printf(" -n/-N No Money in DS\n");
printf(" -o/-O load datafield of te program\n");
printf(" -r/-R Standard-Level For All Nodes\n");
printf(" 2 - blue 3 - green 4 - orange\n");
printf(" 5 - red 6 - purple(if -g) 7 - black(if -g)\n");
printf(" -s/-S Standard-Filename\n");
printf(" -t/-T Description-Output-Text (TeX)\n");
printf(" -u/-U IC protects always informationfiles\n");
printf(" -v/-V IC protects always money in datastore\n");
printf(" -x/-X No ICE in Nodes\n");
printf(" -z/-Z DS-Value +/- 10% Random, Size +/- 5Mp)");
printf("\n");
printf("Default : MatrixGen -a 20 -i 5 -m 2 -s RAM:Matrix\n");
exit(1);
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-s",2)==0)|(strncmp(argv[yi],"-S",2)==0)){
strcpy(StandardName,argv[yi+1]);
strcpy(GfxName,StandardName);
strcat(GfxName,".IFF");
strcpy(TextName,StandardName);
strcat(TextName,".DOC");
}
}
if(((strncmp(argv[1],"-p",2)==0)||(strncmp(argv[1],"-P",2)==0))&&(argc>2)) DisplayErrorMessage("use -p without other options!");
if(((strncmp(argv[1],"-o",2)==0)||(strncmp(argv[1],"-O",2)==0))&&(argc>3)) DisplayErrorMessage("use -o without other options!");
if((strncmp(argv[1],"-p",2)==0)||(strncmp(argv[1],"-P",2)==0)) PrefsFile=TRUE;
if((strncmp(argv[1],"-o",2)==0)||(strncmp(argv[1],"-O",2)==0)){
LoadDataField=TRUE;
strcpy(DatenFeld,argv[2]);
}
if((LoadDataField==FALSE)&&(PrefsFile==FALSE)){
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-a",2)==0)||(strncmp(argv[yi],"-A",2)==0)) stcd_i(argv[yi+1],&AnzahlKnoten);
}
for(yi=2;yi<argc;yi++){
if((strncmp(argv[yi],"-p",2)==0)||(strncmp(argv[yi],"-P",2)==0)) DisplayErrorMessage("option -p without other options!");
}
for(yi=2;yi<argc;yi++){
if((strncmp(argv[yi],"-o",2)==0)||(strncmp(argv[yi],"-O",2)==0)) DisplayErrorMessage("option -o without other options!");
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-h",2)==0)||(strncmp(argv[yi],"-H",2)==0)) Schatten=TRUE;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-x",2)==0)||(strncmp(argv[yi],"-X",2)==0)) InstallNoIC=TRUE;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-c",2)==0)||(strncmp(argv[yi],"-C",2)==0)) CheckLevelCode=TRUE;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-u",2)==0)||(strncmp(argv[yi],"-U",2)==0)) AlwaysICInfo=TRUE;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-v",2)==0)||(strncmp(argv[yi],"-V",2)==0)) AlwaysICDS=TRUE;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-d",2)==0)||(strncmp(argv[yi],"-D",2)==0)) SaveDatenfeld=TRUE;
}
for(yi=1;yi<argc+1;yi++){
if((strncmp(argv[yi],"-b",2)==0)||(strncmp(argv[yi],"-B",2)==0)) BlaueKnoten=TRUE;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-i",2)==0)||(strncmp(argv[yi],"-I",2)==0)) stcd_i(argv[yi+1],&AnzahlWichtigeDaten);
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-m",2)==0)||(strncmp(argv[yi],"-M",2)==0)){
stcd_i(argv[yi+1],&MaxSAN);
MaxSAN++;
}
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-f",2)==0)|(strncmp(argv[yi],"-F",2)==0)){
strcpy(StatusName,StandardName);
strcat(StatusName,".STAT");
StatusFile=TRUE;
}
}
for(yi=1;yi<argc+1;yi++){
if((strncmp(argv[yi],"-g",2)==0)||(strncmp(argv[yi],"-G",2)==0)) MaxFarben=7;
}
for(yi=1;yi<argc;yi++){
if((strncmp(argv[yi],"-l",2)==0)||(strncmp(argv[yi],"-L",2)==0)){
if((strncmp(argv[yi+1],"g",1)==0)||(strncmp(argv[yi+1],"G",1)==0)) Language=1;
else DisplayErrorMessage("option -l, unsupported language");
}
}
for(yi=1;yi<argc+1;yi++){
if((strncmp(argv[yi],"-n",2)==0)||(strncmp(argv[yi],"-N",2)==0)) KeineDatenspeicher=TRUE;
}
for(yi=1;yi<argc+1;yi++){
if((strncmp(argv[yi],"-r",2)==0)||(strncmp(argv[yi],"-R",2)==0)){
Zufallsstufen=FALSE;
stcd_i(argv[yi+1],&Stufenwert);
}
}
for(yi=1;yi<argc+1;yi++){
if((strncmp(argv[yi],"-t",2)==0)|(strncmp(argv[yi],"-T",2)==0)) OutputType=1;
}
for(yi=1;yi<argc+1;yi++){
if((strncmp(argv[yi],"-z",2)==0)|(strncmp(argv[yi],"-Z",2)==0)) RandomDSValue=TRUE;
}
AusgangsWichtigeDaten=AnzahlWichtigeDaten;
if(AnzahlKnoten<5) DisplayErrorMessage("option -a, too few nodes");
if(AnzahlKnoten>100) DisplayErrorMessage("option -a, too much nodes");
if(AnzahlWichtigeDaten<0) DisplayErrorMessage("option -i, greater than 0");
if(AnzahlWichtigeDaten>100) DisplayErrorMessage("option -i, smaller than 100");
if(AnzahlWichtigeDaten>AnzahlKnoten) DisplayErrorMessage("option -i, not more than nodes (-a)");
if(MaxSAN<1) DisplayErrorMessage("option -m, greater than 0");
if(MaxSAN>20) DisplayErrorMessage("option -m, smaller than 20");
if(Stufenwert<2) DisplayErrorMessage("option -r, greater than 2");
if(Stufenwert>MaxFarben) DisplayErrorMessage("option -r, smaller than 5, or 7(if -g)");
AusgangsKnoten=AnzahlKnoten;
}
if(PrefsFile==TRUE) ScanPrefs();
DosBase=(struct Library *)OpenLibrary("dos.library",0L);
GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L);
IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0L);
if((DosBase==0)||(GfxBase==0)||(IntuitionBase==0)) DisplayErrorMessage("Error opening libraries");
if((DosBase==0)||(GfxBase==0)||(IntuitionBase==0)) DisplayErrorMessage("Error opening libraries");
MyNewScreen.LeftEdge=0;
MyNewScreen.TopEdge=0;
MyNewScreen.Width=xSize;
MyNewScreen.Height=ySize;
MyNewScreen.Depth=cBitmaps;
MyNewScreen.DetailPen=1;
MyNewScreen.BlockPen=0;
MyNewScreen.ViewModes=0;
MyNewScreen.ViewModes=0;
if(MyNewScreen.Width>320) MyNewScreen.ViewModes|=HIRES;
if(MyNewScreen.Height>256) MyNewScreen.ViewModes|=LACE;
MyNewScreen.Type=CUSTOMSCREEN;
MyNewScreen.Font=NULL;
MyNewScreen.DefaultTitle="Matrix-Generator V2.4 by Thomas Reinhardt";
MyNewScreen.Gadgets=NULL;
MyNewScreen.CustomBitMap=NULL;
MyScreen=OpenScreen(&MyNewScreen);
if(MyScreen==0) DisplayErrorMessage("No Screen ???");
ShowTitle(MyScreen,FALSE);
SetRGB4(&MyScreen->ViewPort,0,15*17,15*17,15*17); /* weiß */
SetRGB4(&MyScreen->ViewPort,1,0*17,0*17,0*17); /* schwarz */
Colors[0].rot=15*17;
Colors[0].gruen=15*17;
Colors[0].blau=15*17;
Colors[1].rot=0*17;
Colors[1].gruen=0*17;
Colors[1].blau=0*17;
SetRGB4(&MyScreen->ViewPort,2,0*17,0*17,15*17); /* blau */
SetRGB4(&MyScreen->ViewPort,3,0*17,13*17,7*17); /* grün */
SetRGB4(&MyScreen->ViewPort,4,15*17,9*17,0*17); /* orange */
SetRGB4(&MyScreen->ViewPort,5,14*17,0*17,0*17); /* rot */
SetRGB4(&MyScreen->ViewPort,6,15*17,0*17,15*17); /* purpur */
SetRGB4(&MyScreen->ViewPort,7,0*17,0*17,0*17); /* schwarz */
Colors[2].rot=0*17;
Colors[2].gruen=0*17;
Colors[2].blau=15*17;
Colors[3].rot=0*17;
Colors[3].gruen=13*17;
Colors[3].blau=7*17;
Colors[4].rot=15*17;
Colors[4].gruen=9*17;
Colors[4].blau=0*17;
Colors[5].rot=14*17;
Colors[5].gruen=0*17;
Colors[5].blau=0*17;
Colors[6].rot=15*17;
Colors[6].gruen=0*17;
Colors[6].blau=15*17;
Colors[7].rot=0*17;
Colors[7].gruen=0*17;
Colors[7].blau=0*17;
SetRGB4(&MyScreen->ViewPort,8,5*17,5*17,5*17); /* hellgrau */
SetRGB4(&MyScreen->ViewPort,9,6*17,6*17,6*17); /* .. */
SetRGB4(&MyScreen->ViewPort,10,7*17,7*17,7*17); /* .. */
SetRGB4(&MyScreen->ViewPort,11,8*17,8*17,8*17); /* .. */
SetRGB4(&MyScreen->ViewPort,12,9*17,9*17,9*17); /* .. */
SetRGB4(&MyScreen->ViewPort,13,10*17,10*17,10*17); /* .. */
SetRGB4(&MyScreen->ViewPort,14,11*17,11*17,11*17); /* .. */
SetRGB4(&MyScreen->ViewPort,15,12*17,12*17,12*17); /* dunkelgrau */
SetDrMd(&MyScreen->RastPort,JAM2);
Colors[8].rot=5*17;
Colors[8].gruen=5*17;
Colors[8].blau=5*17;
Colors[9].rot=6*17;
Colors[9].gruen=6*17;
Colors[9].blau=6*17;
Colors[10].rot=7*17;
Colors[10].gruen=7*17;
Colors[10].blau=7*17;
Colors[11].rot=8*17;
Colors[11].gruen=8*17;
Colors[11].blau=8*17;
Colors[12].rot=9*17;
Colors[12].gruen=9*17;
Colors[12].blau=9*17;
Colors[13].rot=10*17;
Colors[13].gruen=10*17;
Colors[13].blau=10*17;
Colors[14].rot=11*17;
Colors[14].gruen=11*17;
Colors[14].blau=11*17;
Colors[15].rot=12*17;
Colors[15].gruen=12*17;
Colors[15].blau=12*17;
BMHD.w=xSize;
BMHD.h=ySize;
BMHD.x=0;
BMHD.y=0;
BMHD.nPlanes=cBitmaps;
BMHD.pad1=0;
BMHD.transparentColor=0;
BMHD.xAspect=0;
BMHD.yAspect=0;
BMHD.Width=xSize;
BMHD.Height=ySize;
if(LoadDataField==TRUE){
LoadData(DatenFeld);
}
else{
MatrixDatas[0].Version=MGVersion;
MatrixDatas[0].Revision=MGRevision;
MatrixDatas[0].xLength=12;
MatrixDatas[0].yLength=12;
MatrixDatas[0].Speak=Language;
MatrixDatas[0].cBitmaps=cBitmaps;
MatrixDatas[0].AnzahlKnoten=AnzahlKnoten;
MatrixDatas[0].AusgangsKnoten=AusgangsKnoten;
MatrixDatas[0].AnzahlWichtigeDaten=AnzahlWichtigeDaten;
MatrixDatas[0].Stufenwert=Stufenwert;
MatrixDatas[0].MaxSAN=MaxSAN;
MatrixDatas[0].AusgangsWichtigeDaten=AusgangsWichtigeDaten;
MatrixDatas[0].MaxFarben=MaxFarben;
MatrixDatas[0].OutputType=OutputType;
MatrixDatas[0].CPUInSystem=CPUInSystem;
MatrixDatas[0].Beenden=Beenden;
MatrixDatas[0].RandomDSValue=RandomDSValue;
MatrixDatas[0].Zufallsstufen=Zufallsstufen;
MatrixDatas[0].KeineDatenspeicher=KeineDatenspeicher;
MatrixDatas[0].StatusFile=StatusFile;
MatrixDatas[0].PrefsFile=PrefsFile;
MatrixDatas[0].BlaueKnoten=BlaueKnoten;
MatrixDatas[0].Schatten=Schatten;
MatrixDatas[0].SaveDatenfeld=SaveDatenfeld;
MatrixDatas[0].InstallNoIC=InstallNoIC;
MatrixDatas[0].AlwaysICInfo=AlwaysICInfo;
MatrixDatas[0].AlwaysICDS=AlwaysICDS;
for(yi=0;yi<12;yi++){
for(xi=0;xi<12;xi++){
Matrix[xi+yi*12].Belegt=FALSE;
Matrix[xi+yi*12].Type=0;
Matrix[xi+yi*12].Nummer=0;
if(Zufallsstufen==FALSE) Matrix[xi+yi*12].Secure=Stufenwert;
else Matrix[xi+yi*12].Secure=0;
Matrix[xi+yi*12].Stufe=0;
Matrix[xi+yi*12].Datenwert=0;
Matrix[xi+yi*12].Datensize=0;
Matrix[xi+yi*12].WichtigeDaten=FALSE;
Matrix[xi+yi*12].ICType=0;
Matrix[xi+yi*12].ICArt=0;
Matrix[xi+yi*12].N=FALSE;
Matrix[xi+yi*12].NO=FALSE;
Matrix[xi+yi*12].O=FALSE;
Matrix[xi+yi*12].SO=FALSE;
Matrix[xi+yi*12].S=FALSE;
Matrix[xi+yi*12].SW=FALSE;
Matrix[xi+yi*12].S=FALSE;
Matrix[xi+yi*12].NW=FALSE;
}
}
MatrixGenerierung();
MatrixKorrektur();
MatrixEditKanten();
MatrixStufe();
MatrixCheckLevelCode();
MatrixDatenspeicher();
MatrixInstallIC();
}
MatrixDarstellung();
MatrixNummerierung();
SaveIFF(GfxName);
if(SaveDatenfeld==TRUE) SaveData(DatenFeld);
StatusAusgabe(StatusName);
SaveText();
DisplayErrorMessage("IFF and Text saved ...");
}
void DisplayErrorMessage(char *Meldung){
printf("%s\n",Meldung);
if(SaveNamePointer) Close(SaveNamePointer);
if(MyScreen) CloseScreen(MyScreen);
if(DosBase) CloseLibrary(DosBase);
if(GfxBase) CloseLibrary((struct Library *)GfxBase);
if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
exit(TRUE);
}
void AusgabeText(ULONG xW,ULONG yW,ULONG farbe,char *ThisText){
LONG zwsp;
char HelpText[10];
struct IntuiText OutputText[1];
strcpy(HelpText,ThisText);
OutputText[0].FrontPen=farbe;
OutputText[0].BackPen=0;
OutputText[0].DrawMode=JAM1;
OutputText[0].LeftEdge=xW+15;
OutputText[0].TopEdge=yW-3;
OutputText[0].ITextFont=0;
OutputText[0].NextText=NULL;
OutputText[0].IText=HelpText;
zwsp=IntuiTextLength(&OutputText[0])/2;
OutputText[0].LeftEdge-=zwsp;
PrintIText(&MyScreen->RastPort,&OutputText[0],0,0);
}